<?php
class Plugin_MenuPlugin extends Zend_Controller_Plugin_Abstract
{
	protected $_menu;
    
    public function preDispatch( Zend_Controller_Request_Abstract $request )
	{
		$view = Zend_Layout::getMvcInstance()->getView();
		$auth = Zend_Auth::getInstance();
		
		if ( !$auth->hasIdentity() ) {
			$this->_menu = '<div class="right"><a href="/login/">Login</a></div>';
		} else {
			
			$username = $auth->getIdentity();
			
			if (Zend_Session::namespaceIsset('Zend_Auth') ){
    			$authSession = new Zend_Session_Namespace('Zend_Auth');
			}
			
			//TODO dit moet nog in een template worden gegoten
			$this->_menu = '<div class="left"><a href="/">Home</a></div><div class="left">&nbsp;</div> <div class="left"><a href="/klacht/">Klacht</a></div> <div class="left">&nbsp;</div> <div class="left"><a href="/faq/">FAQ</a></div>';
			$this->_menu .= '<div class="right"><span>Welkom ' . $username . '</span> <a href="/login/logout/">Logout</a></div>';
		} 	
	        
		$response = $this->getResponse();
		$response->insert('menu', $this->_menu);

	}
	
}
